<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>管理后台</title>
    <link rel="stylesheet/less" href="../../../static/css/index.less"/>
    {#    <link rel="stylesheet/less" href="../../static/admin/css/user_huafen_record.less"/>#}
    <link rel="stylesheet" href="../../../static/layui/css/layui.css"/>
    <link rel="stylesheet" href="../../../static/css/jquery.pagination.css"/>
    <script src="../../../static/js/jquery-1.12.3.js"></script>
    <script src="../../../static/js/less.min.js"></script>
    <script src="../../../static/layui/layui.js"></script>
    <SCRIPT language=javascript src="../../../static/layer/layer.js"></SCRIPT>

</head>
<style>
    .js_w {
        width: 40px;
        height: 25px;
        font-size: 12px;
        line-height: 25px;
    }

    .ll {
        width: 40px;
        height: 25px;
        font-size: 12px;
        line-height: 25px;
    }

    .newadd label {
        padding: 10px 0;
        display: block;
        text-align: left;
    }

    .newadd label .adtitle {
        display: inline-block;
        width: 6rem;
        text-align: right;
        padding-right: 2%;
    }

    .newadd label span {
        text-align: right;
        padding-right: 2%;
    }

    .newadd input {
        padding: 0 10px;
        width: 20%;
        height: 30px;
        line-height: 30px;
        border: 1px solid #dcdcdc;
        border-radius: 5px;
    }

    .newadd select {
        text-align: left;
        padding: 0 5px;
        width: 20%;
        height: 30px;
        line-height: 30px;
        border: 1px solid #dcdcdc;
        border-radius: 5px;
    }

    .subbtn {
        margin-left: 5%;
        padding: 2px 3px;
    }
</style>
<body class="layui-layout-body">

{% include "/admin/top.html" %}
{% include "/admin/left.html" %}


<div id="box" class="fl">
    <div class="content" style="height: 100%">
        <div class="content">
            <h3 style="color:  #3D89CB">赠送套餐</h3>
            <div class="newadd">
                <label>
                    <span class="adtitle">商家名</span>
                    <span>{{ business.nickname | default('', true) }}</span>
                </label>
                <label>
                    <span class="adtitle">可用余额</span>
                    <span>{{ business.money | default('0', true) }}</span>
                </label>
                <label>
                    <span class="adtitle">剩余次数</span>
                    <span>{{ business.wash_num | default('0', true) }}</span>
                </label>
                <label>
                    <span class="adtitle">选择套餐</span>
                    <select id="suit">
                        <option value="">选择套餐</option>
                        {% if suit %}
                            {% for d in suit %}
                                <option value="{{ d.suit_id }}">{{ d.name }}-{{ d.num }}</option>
                            {% endfor %}
                        {% endif %}
                    </select>
                </label>
                <label for="">
                    <button onclick="add_give()" class="subbtn" style="width: 60px;height: 30px;margin-left: 200px;background-color: #3D89CB">提交</button>
                </label>
            </div>
        </div>
    </div>
</div>
</body>
</html>
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //常规用法
        laydate.render({
            elem: '#test1'
        });
    });
    function add_give(){
        var suit = $('#suit').val();
        if (suit == ""  ) {
            layer.msg('请选择套餐');
            return
        }
        $('.subbtn').attr("disabled","disabled");
        $.ajax({
            url: "/admin/give_business_post",
            type: 'post',
            data: {
                'suit': suit,
                'bid':{{ business.bid }}
            },
            dataType: 'json',
            success: function (msg) {
                if (msg.status == 1) {
                    layer.msg("添加成功",{time:1500},function(){
                        location.href = '/admin/business_list.html';
                    });

                } else if (msg.status == 2) {
                    $('.subbtn').removeAttr("disabled");
                    layer.msg("商家不存在")
                } else if (msg.status == 3) {
                    $('.subbtn').removeAttr("disabled");
                    layer.msg("套餐不存在")
                }else {
                    $('.subbtn').removeAttr("disabled");
                    layer.msg("系统错误")
                }
            }
        })
    }


</script>

